

#include <sys/cdefs.h>

__RCSID("$ : __aeabi_idiv0.c,v 1.3 2014/01/29 22:29:43 joerg Exp $");

#if defined(_KERNEL) || defined(_STANDALONE)
#include <sys/systm.h>
#else
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/signal.h>
#include <sys/siginfo.h>
#endif

#include <arm/aeabi.h>

int
__aeabi_idiv0(int result)
{
#if defined(_KERNEL) || defined(_STANDALONE)
	panic("divide by 0");
#else
#if !defined(__alioth) /* LSC: No sigqueueinfo on alioth. */
	siginfo_t info;
	
	memset(&info, 0, sizeof info);
	info.si_signo = SIGFPE;
	info.si_pid = getpid();
	info.si_uid = geteuid();
	info.si_code = FPE_INTDIV;
	sigqueueinfo(getpid(), &info);
#else
	/* LSC: So just trigger the signal. */
	raise(SIGFPE);
#endif /* !defined(__alioth) */
#endif
	return result;
}
